<?php
class Integral_ruleAction extends CommonAction {
	
	
	
	
	public function index(){
        $map['r.site_id']=$this->siteid;
		$pid_list=$this->dao->getList2(0,0,$map);
		$this->assign('pid_list',$pid_list);
		$this->display();
	}
	public function delete(){
		if($this->_get('id')){
			$_POST['id']=$this->_get('id');
			parent::delete();
		}
	}
	public function add(){
        $map['r.site_id']=$this->siteid;
		$this->pid_list=$this->dao->getList2(0,0,$map);
		$ruletype=D('integral_ruletype')->where(array('site_id'=>$this->siteid))->select();
		$membergroup=M('member_group')->where(array('pid'=>0,'site_id'=>__SITEID__))->select();
		$this->assign('membergroup',$membergroup);
		$this->assign('ruletype',$ruletype);
		parent::add();
	}
	public function edit(){
		$pid_list=$this->dao->where(array('id'=>$this->_get('id'),'site_id'=>$this->siteid))->select();
        $this->pid_list=$pid_list;
		$ruletype=D('integral_ruletype')->where(array('site_id'=>$this->siteid))->select();
		$membergroup=M('member_group')->where(array('pid'=>0,'site_id'=>__SITEID__))->select();
		$this->assign('membergroup',$membergroup);
		$this->assign('ruletype',$ruletype);
		$this->assign('pid_list',$pid_list);
		parent::edit();
	}
	public function update(){
		if($this->_post('id')){
			parent::update();
		}
	}
	public function insert(){
		$_POST['site_id'] =$this->siteid;
		parent::insert();
	}
    public function getmember(){
		if($this->_get('groupid')){
			$groupid=$this->_get('groupid');	
			$member=D("Member")->getgroupmember($groupid);
			echo json_encode(array('member'=>$member,'statu'=>1));
		}  
    }
	
	
	
	//选择列表
	public function select(){
		$this->pagesize = 15;
		$this->listmap = "site_id = ". __SITEID__;
		if($this->_get('selected') && $this->_get('selected') != ''){
			$this->pagesize = 100;
			$this->listmap = "id in(".$this->_get('selected').")";
		}
		if($this->_param('keywords')){
			$keywords=$this->_param('keywords');
			$_GET['keywords']=urlencode($this->_param('keywords'));
			$this->listmap.=" and title like '%{$keywords}%'";
			$this->keywords=$keywords;
		}
		parent::_list();
		$list = $_GET['list'];
		$statu=$list?1:0;
		if(IS_AJAX){
			die(json_encode(array('tbody'=>$this->fetch(),'dump'=>$_REQUEST,'statu'=>$statu, 'pages' => $this->get('pages'))));	
		}else{
			$this->display();
		}
		
		
	}
	
	
	
	
	
	
	
	
	
}

?>